﻿using B.S.DataBase.MyProject.Domain.Procurements;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.E.ERP.Read.API.Applicantions.Command.ProcurementsCommand;
using T.E.ERP.Read.API.Dtos.Dtos;

namespace T.E.ERP.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PurchaseInvoiceController : ControllerBase
    {
        private readonly IMediator mediator;

        public PurchaseInvoiceController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 采购发票列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<PurchaseDTO>>> GetPurchaseInvoice(long documentcode,string? invoicenumber,DateTime? begindate,DateTime? enddate)
        {
            GetPurchaseCommand command=new GetPurchaseCommand();
            command.DocumentCode = documentcode;
            command.InvoiceNumber = invoicenumber;
            command.BeginDate = begindate;
            command.EndDate = enddate;
            return await mediator.Send(command);
        }

        /// <summary>
        /// 采购退货单列表
        /// </summary>
        /// <param name="material_code"></param>
        /// <param name="material_name"></param>
        /// <param name="begindate"></param>
        /// <param name="enddate"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<PreturnorderDTO>>> GetPreturnorder()
        //long material_code,string? material_name,DateTime? begindate,DateTime? enddate
        {
            GetPreturnorderCommand command = new GetPreturnorderCommand();
            //command.material_code = material_code;
            //command.material_name = material_name;
            //command.BeginDate= begindate;
            //command.EndDate= enddate;
            return await mediator.Send(command);
        }



        /// <summary>
        /// 采购订单列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<SupplierDto>>> GetPurchaseorderlsit ([FromQuery] PurchaseorderCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 采购订单明细
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<SupplierDto>>> DetailsPurchaseorderlsit([FromQuery] DetailsPurchaseorderCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 采购到货查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<PurchaseArrivalDto>>> GetPurchaseArrival([FromQuery] GetPurchaseArrivalCommd command)
        {
            return await mediator.Send(command);
        }



        /// <summary>
        /// 采购到货明细
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<PurchaseArrivalDto>>> DetailsPurchaseArrival([FromQuery] DetailsPurchaseArrivalCommd command)
        {
            return await mediator.Send(command);
        }

    }
}
